package com.x.provider.general.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.x.core.wrapper.mybatisplus.CrudMapper;
import com.x.provider.general.model.domain.cms.Category;
import com.x.provider.general.model.domain.place.Region;
import com.x.provider.general.model.query.place.RegionQuery;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Mapper
public interface RegionMapper extends CrudMapper<Region, RegionQuery> {

    @Override
    default void buildQuery(RegionQuery regionQuery, LambdaQueryWrapper<Region> queryWrapper){
        queryWrapper.eq(regionQuery.getRegionType() != null, Region::getRegionType, regionQuery.getRegionType());
        queryWrapper.eq(!StrUtil.isEmpty(regionQuery.getCode()), Region::getCode, regionQuery.getCode());
    }

}
